package br.ucb.rest.persistencia.vo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name="rst_conta")
@SequenceGenerator(name="ContaVO.seq", sequenceName="restaurante.rst_conta_nu_conta_seq")
@NamedQueries({
	@NamedQuery(name="ContaVO.recuperarEmAberto", 
		query="SELECT a FROM ContaVO a " +
			"WHERE a.idIpad = :idIpad " +
			"AND a.dtFechamento IS NULL ")
})
public class ContaVO implements Serializable {
	private static final long serialVersionUID = 462770191081406440L;
	
	@Id
	@Column(name="nu_conta", nullable=false)
	@GeneratedValue(generator="ContaVO.seq", strategy=GenerationType.AUTO)
	private Integer nuConta;
	@Column(name="id_ipad", nullable=false)
	private String idIpad;
	@Column(name="dt_abertura", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date dtAbertura;
	@Column(name="dt_fechamento", nullable=true)
	@Temporal(TemporalType.TIMESTAMP)
	private Date dtFechamento;
	@OneToMany(mappedBy="contaVO", fetch=FetchType.EAGER)
	private List<ContaPedidoVO> colContaPedidoVO;
	
	public Integer getNuConta() {
		return nuConta;
	}
	public void setNuConta(Integer nuConta) {
		this.nuConta = nuConta;
	}
	public String getIdIpad() {
		return idIpad;
	}
	public void setIdIpad(String idIpad) {
		this.idIpad = idIpad;
	}
	public Date getDtAbertura() {
		return dtAbertura;
	}
	public void setDtAbertura(Date dtAbertura) {
		this.dtAbertura = dtAbertura;
	}
	public Date getDtFechamento() {
		return dtFechamento;
	}
	public void setDtFechamento(Date dtFechamento) {
		this.dtFechamento = dtFechamento;
	}
	public List<ContaPedidoVO> getColContaPedidoVO() {
		return colContaPedidoVO;
	}
	public void setColContaPedidoVO(List<ContaPedidoVO> colContaPedidoVO) {
		this.colContaPedidoVO = colContaPedidoVO;
	}
	
		
	
}
